
local MyApp = class("MyApp", cc.load("mvc").AppBase)

function MyApp:onCreate()
	self.resScale_ = 2
    math.randomseed(os.time())

    -- global varibale
	cc.exports.MyApp = self
	_init()

end

function MyApp.getScheduler()
	Schedule = cc.Director:getInstance():getScheduler()
end

function MyApp.invokeFuncASync(func, time)
	time = time or 0.1
	local handle
	Schedule = cc.Director:getInstance():getScheduler()
    handle = Schedule:scheduleScriptFunc(function()
        Schedule:unscheduleScriptEntry(handle)
        func()
    end, time, false)
    return handle
end

function MyApp.getTablesVersion()
	return VERSIONS[VERSIONS_INDEX].tables
end

function MyApp.getResVersion()
	return VERSIONS[VERSIONS_INDEX].res
end


function MyApp.getIsSuperluck()
	return VERSIONS[VERSIONS_INDEX].isSuperluck
end


_init = function()

	local VERSIONS = 
	{
	{tables = "zh_CN", res = "zh_CN", isSuperluck = true }, 
	{tables = "zh_CN", res = "zh_CN", isSuperluck = true }, 
	{tables = "zh_CN", res = "zh_CN", isSuperluck = true }, 
	{tables = "zh_CN", res = "zh_CN", isSuperluck = true },
	}
	cc.exports.VERSIONS = VERSIONS
 
	cc.FileUtils:getInstance():addSearchPath("res/" .. MyApp.getResVersion())
	display.loadSpriteFrames("ui/ui.plist", "ui/ui.png")
	display.loadSpriteFrames("ui/emot.plist", "ui/emot.png")

	--定义全局变量  有些是可以放到进入游戏后在初始化的  可以加快进入游戏  后面处理
	cc.exports.Word = function(index)

	    if not cc.exports["WordC_" .. index] then
	        cc.exports["WordC_" .. index] = require ("app.tables." .. MyApp.getTablesVersion() .. ".Word_" .. index)
	    end

	    return cc.exports["WordC_" .. index]

	end
	require "app.models.Functions"
	cc.exports.Constants           = require "app.models.Constants"
	cc.exports.ManagerNotification = require "app.models.ManagerNotification"
	cc.exports.ManagerCookie       = require "app.models.ManagerCookie"
	cc.exports.TextPaser           = require "app.models.TextPaser"
	cc.exports.Tips                = require "app.viewsComponent.Tips"
	--cc.exports.ManagerLabel      = require "app.models.ManagerLabel"
	
	cc.exports.ManagerNet          = require("app.models.ManagerNet").getInstance()
	cc.exports.ManagerRes          = require("app.models.ManagerRes").getInstance()
	cc.exports.ManagerUserData     = require("app.models.ManagerUserData").getInstance()
	cc.exports.ManagerChatData     = require("app.models.ManagerChatData").getInstance()
	cc.exports.AdapterSendMsg      = require("app.models.AdapterSendMsg").getInstance()
	cc.exports.ManagerMap          = require("app.models.ManagerMap").getInstance()

	print("test start")
	--repair label android 和 ios 字大小不一样 
	-- cc.LabelTTF.setFontSize = function(size)
	-- 	if device.platform == "mac" then
	-- 		size = size * 1
	-- 	if device.platform == "android" then 
	-- 		size = size * 0.9
	-- 	elseif device.platform == "ios" then
	-- 		size = size * 1
	-- 	end


	-- end	
	--require("app.geo")


end

return MyApp
